home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-20 | 2.6 KB | 104 lines | [TEXT/MPS ] |
- # SSCompile
- #
- # This uses the SendAE tool and the ScriptServer application to
- # compile text files into AppleScripts.
- #
- # Written by Ult Mundane & Jon Pugh
- #
- # Option -c: Preprocess with C compiler first.
- # Option -e: Preprocess with UltScript compiler first.
- # Option -p: Preprocess only; don't compile with AppleScript
- # Option -s: Launch ScriptServer before trying to send Apple events to it
- #
- # {1} is the file to compile
- # {2} is the output script file
-
- Unset lSource
- Unset lTarget
-
- Loop
- If "{1}" == ""
- Break
- Else If "{1}" == "-c"
- Set lPreprocessC TRUE
- Else If "{1}" == "-e"
- Set lPreprocessUltScript TRUE
- Else If "{1}" == "-s"
- Set lLaunchScriptServer TRUE
- Else If "{1}" == "-p"
- Set lPreprocessOnly TRUE
- Else If "{lSource}" == ""
- Set lSource "{1}"
- Set lOrigSource "{lSource}"
- Else If "{lTarget}" == ""
- Set lTarget "{1}"
- Else
- Echo "### SSCompile - Too many parameters"
- Exit
- End
- Shift
- End
-
- If "{lTarget}" == ""
- Set lPreprocessOnly TRUE
- End
-
- If {lPreprocessC} == TRUE || {lPreprocessUltScript} == TRUE
- If {lPreprocessC} == TRUE
- C -e2 "{lSource}" > "{TempFolder}"Temp
- # Strip compiler comments
- StreamEdit "{TempFolder}"Temp -e '/•[∂#]/ Delete' -o "{TempFolder}"Temp
- Else
- Catenate "{lSource}" > "{TempFolder}"Temp
- End
-
- If {lPreprocessUltScript} == TRUE
- # I tried using StreamEdit to strip the blank lines at the
- # beginning of the file, but it always seems to insert one blank line.
- Target "{TempFolder}"Temp
- SizeWindow 20 20 "{TempFolder}"Temp
-
- # Don't exit just because a Find/Replace failed
- Set lStartExit {Exit}
- Set Exit 0
-
- # Replace "#include <file>" with the contents of <file>
- Find • "{TempFolder}"Temp
- Loop
- Find /∂#include [∂"∂<](≈)®1[∂"∂>]∂n/ "{TempFolder}"Temp
- Break If {Status} != 0
- Set lInclude "`Catenate "{TempFolder}"Temp.§`"
- Continue If "{lInclude}" !~ /∂#include [∂"∂<]«0,1»(≈)®1[∂"∂>]«0,1»/
- Catenate `WhereIs "{®1}" -s "{gProjectDir}"` > "{TempFolder}"Temp.§
- End
-
- # Remove all c style comments (/* comment */)
- Find • "{TempFolder}"Temp
- Replace -c ∞ /[ ∂t]*∂/∂*/:/∂*∂/[∂n ∂t]«0,1»/ "" "{TempFolder}"Temp
- Set Exit {lStartExit}
- Close -y "{TempFolder}"Temp
- End
-
- Set lSource "{TempFolder}"Temp
- End
-
- If {lLaunchScriptServer} == TRUE
- ScriptServer
- End
-
- If {lPreprocessOnly} == TRUE
- If "{lTarget}" == ""
- Catenate "{lSource}" >> "{Worksheet}"
- Else
- Catenate "{lSource}" > "{lTarget}"
- End
- Else
- If "`Exists -q "{lTarget}"`"
- Move -y "{lTarget}" "{TempFolder}"
- End
- sendAE -e JonSCmpl -t ScriptServer -timeout 18000 -----alis "{lSource}" -"to TEXT" "{lTarget}"
- If !"`Exists -q "{lTarget}"`"
- Echo "### SSCompile - Error compiling ∂"{lOrigSource}∂"."
- End
- End
-